#!/bin/sh

# Slackware build script for hatari_tos_roms
# Written by B. Watson (yalhcru@gmail.com)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# The version number is just the date when the script was written.
# The actual TOS ROM versions are 1.02, 1.04, 2.06

# 20141029 bkw: fix missing : in VERSION BUILD TAG assignments

# 20140825 bkw:
# - include the 1.04 images, since hatari needs them to allow direct
#   launching of .prg files from the command line.
# - simplify script, the US images used to be optional, now they're
#   required, and we don't need code to modify the slack-desc either.

# I thought about gzipping these, since hatari supports gzipped roms, but
# they're not taking up that much space (1088K uncompressed, 670K gzipped),
# plus other emulators than hatari can use these, and might not support .gz

PRGNAM=hatari_tos_roms
VERSION=${VERSION:-20140825}
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

set -e

rm -rf $PKG
mkdir -p $PKG/usr/share/hatari $PKG/install

cd $PKG/usr/share/hatari

unzip $CWD/tos_uk.zip
unzip $CWD/tos_us.zip
unzip $CWD/tos104uk.zip
unzip $CWD/tos104us.zip

mv Tos206.img tos-2.06-uk.img
mv Tos102.img tos-1.02-uk.img
mv Tos206us.img tos-2.06-us.img
mv Tos102us.img tos-1.02-us.img
mv tos104uk.img tos-1.04-uk.img
mv tos104us.img tos-1.04-us.img

chown root:root *
chmod 644 *

cat $CWD/slack-desc >$PKG/install/slack-desc
cat $CWD/doinst.sh >$PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
